<?php
/**
 * 用户模型
 * User: admin
 * Date: 2018/3/16
 * Time: 15:20
 */

namespace Admin\Model;
use Think\Model;

class UserModel extends Model
{

    /**
     * 收货地址
     */
    public function getReceive($uid){
        $list = M('Member_receive')->where('uid='.$uid)->order('create_time desc')->select();
        foreach ($list as &$li){
            $li['province'] = M('hat_province')->where('province_id='.$li['province_id'])->getField('province');
            $li['city'] = M('hat_city')->where('city_id='.$li['city_id'])->getField('city');
            $li['area'] = M('hat_area')->where('area_id='.$li['area_id'])->getField('area');
            $li['address'] = $li['province'].$li['city'].$li['area'].$li['address'];
            if($li['is_default']){
                $li['default'] = "是";
            }else{
                $li['default'] = "否";
            }
        }
        return $list;
    }

    /**
     * 用户详情
     */
    public function getuserDetail($uid){
        $user = M('Ucenter_member')->where('id='.$uid)->find();
        $member = M('member')->where('uid='.$uid)->find();
        $user['nickname'] = $member['nickname'];
        $user['avatar_url'] =M('picture')->where('id='.$member['avatar'])->getField('path');
        //echo $user['avatar_url'];
        $user['coin'] = $member['coin'];
        $user['amount'] = $member['amount'];
        return $user;
    }

}